package shop;

import java.util.ArrayList;

public class UserList {
static private ArrayList<User> user = new ArrayList<User>();
	
	public void addUser(String name,String password) {
		user.add(new User(name,password));		
	}
	
	public boolean Login(String name,String password){
		for (int i = 0; i < user.size(); i++) {
			if(name.equals(user.get(i).getUserName())) {
				if(password.equals(user.get(i).getUserPassword())) return true;
			}
		}
		System.out.println("登录失败");
		return false;
	}
	
	public int GetIn(String name) {
		for (int i = 0; i < user.size(); i++) {
			if(name.equals(user.get(i).getUserName())) {
				return i;
			}
		}
		return -1;
	}
	
	public User UserCar(int i) {
		return user.get(i);
	}
}
